<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"www.lixiaofei.cn","root":"/","scheme":"Mist","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":true,"storage":true,"lazyload":true,"nav":{"valine":{"order":-1}}},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="作为开发者，需要一套开发环境，以便开发和调试程序。 做好的程序，如何在才能被其他人用呢？ 为啥之间把代码拷贝过去无法使用呢？">
<meta property="og:type" content="article">
<meta property="og:title" content="Python 程序，怎么跑起来的？">
<meta property="og:url" content="http://www.lixiaofei.cn/2021-11-18-python-env/index.html">
<meta property="og:site_name" content="管窥程序">
<meta property="og:description" content="作为开发者，需要一套开发环境，以便开发和调试程序。 做好的程序，如何在才能被其他人用呢？ 为啥之间把代码拷贝过去无法使用呢？">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-11-18T14:42:04.000Z">
<meta property="article:modified_time" content="2021-11-18T16:21:18.710Z">
<meta property="article:author" content="太阳雪">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://www.lixiaofei.cn/2021-11-18-python-env/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>Python 程序，怎么跑起来的？ | 管窥程序</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">管窥程序</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Today is a gift</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

  <a href="https://github.com/alisx" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://www.lixiaofei.cn/2021-11-18-python-env/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="太阳雪">
      <meta itemprop="description" content="总结 技术 思考 想法">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="管窥程序">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          Python 程序，怎么跑起来的？
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-11-18 22:42:04" itemprop="dateCreated datePublished" datetime="2021-11-18T22:42:04+08:00">2021-11-18</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-11-19 00:21:18" itemprop="dateModified" datetime="2021-11-19T00:21:18+08:00">2021-11-19</time>
              </span>

          
            <span id="/2021-11-18-python-env/" class="post-meta-item leancloud_visitors" data-flag-title="Python 程序，怎么跑起来的？" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="far fa-comment"></i>
      </span>
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2021-11-18-python-env/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/2021-11-18-python-env/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>作为开发者，需要一套开发环境，以便开发和调试程序。</p>
<p>做好的程序，如何在才能被其他人用呢？</p>
<p>为啥之间把代码拷贝过去无法使用呢？</p>
<a id="more"></a>
<h2 id="程序的由来">程序的由来</h2>
<p>电脑是由很多电子元件组成了，通过高电位和低电位表示两种不同的状态，然后通过大规模集成电路，将上亿的电子原件组合起来，表示更复杂的状态，表达信息。</p>
<p>在发展过程中，不同的厂商有不同的组织标准和实现方案，也就有不同的指挥调度命令。</p>
<p>将电脑上的指令组合起来，就成为了让电脑运行的程序。</p>
<p>程序员就是按照这些指令的规则，编写出能驱动电脑的程序。</p>
<p>可以看出，程序是不许符合某种电脑指令要求的，也就是用的是那种电脑的指令写的程序，就只能在那种电脑上运行。</p>
<p>这显然不符合发展要求，于是人们就提出了统一的编程接口，根据这些接口，设计编程语言，这样不但摆脱了具体电脑类型的束缚，而且还可以设计出更符合人类思维的编程语言。</p>
<p>这个过程就是程序发展的不完整的简要过程。</p>
<h2 id="程序的运行">程序的运行</h2>
<p>写好的程序，如何运行起来呢？</p>
<p>因为程序以及不再是机器能之间识别的指令集合，所以需要先对程序进行编译，让器转化为更接近机器运行的代码。</p>
<p>另外，程序中需要用到很多操作系统的功能，比如读取文件，进行网络访问等等，这些功能编写起来不但复杂，而且质量要求很高，不是一般程序员能搞得定的。</p>
<p>于是有一些公司、社区和高级程序员，将对操作系统的调用编写成模块，组件和功能块，同其他程序员使用，这就是常说的库。</p>
<p>当需要调用系统功能时，可以利用相应的库来实现，比如 Python 中打开一个文件的代码是：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">file = open(<span class="string">"text.txt"</span>, <span class="string">'r'</span>, <span class="string">'utf-8'</span>)</span><br></pre></td></tr></table></figure>
<p>其中 open 就是 Python 中提供的调用操作系统而提高的库方法。</p>
<p>在程序运行之前，还需要编译这些被调用的库，这个过程被称为 <strong>链接</strong>。</p>
<p>最后，在根据具体的电脑类型，将代码编译成可执行文件，在不同的但类型相同的电脑上，就可以运行了。</p>
<h2 id="python">python</h2>
<blockquote>
<p>人生苦短，我用 Python</p>
</blockquote>
<p>这是 Python 里一句著名的 Slog，之所以这么说，是因为 Python 里有大量的库，包括官方的和第三方的，从基本处理，到人工智能，应有尽有。</p>
<p>使用这些库，往往几行代码就可以实现复杂的功能，比如提取一个页面内容的代码：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> requests</span><br><span class="line"></span><br><span class="line">response = requests.get(<span class="string">"http://www.baidu.com"</span>)</span><br><span class="line"></span><br><span class="line">print(response.text)</span><br></pre></td></tr></table></figure>
<p>引入 requests 库，通过 get 方法，就可以获得一个页面的所有数据，而不用关注复杂的链接建立和处理过程。</p>
<p>随着 Python 社区的蓬勃发展，Python 的库，形成了巨大的规模，不可能在一台电脑上安装所有的库，而应该是用到什么安装什么才对。</p>
<p>实际上也就是这么用的，比如上面代码中用到了 requests 库，它不随 Python 环境一起安装，所以使用之前可以通过下面的命令安装：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install requests</span><br></pre></td></tr></table></figure>
<p>不过问题来了，写代码时安装了一下库，将代码拿到其他机器上跑，其他机器可不一定安装了依赖的库，不就运行不了了吗？</p>
<p>确实是，所以需要开发环境中，安装了什么，就在要运行的环境中安装什么。</p>
<p>为了方便，Python 引入了一个概念，叫 —— 虚拟环境。</p>
<h2 id="虚拟环境">虚拟环境</h2>
<p>之所以叫虚拟环境，就是相对于实际环境而起名的。</p>
<p>什么是实际环境呢？</p>
<p>当安装好 Python 之后，在命令行中，输入：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python -h</span><br></pre></td></tr></table></figure>
<p>如果能看到大段的 Python 帮助说明，那么这个环境就是实际环境，其实叫公共环境更好，意思是任何在这个电脑上的 Python 程序都可以使用这个环境。</p>
<p>比如安装了 requests 库，在写一个 Python 程序照样可以用。</p>
<p>如果我们写了很多程序，而每种程序用到不同的库，这些库都被装在实际环境中了，当要迁移程序时，就不能方便的知道要迁移的程序，到底用了哪些库。</p>
<p>等迁移到其他机器上，不是少了库就是多了库。</p>
<p>如果能为每个程序单独创建一个环境就好了。</p>
<p>Python 也想到了这一点，而且提供了简单的创建方法。</p>
<h2 id="创建虚拟环境">创建虚拟环境</h2>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python -m venv .env</span><br></pre></td></tr></table></figure>
<p>这段代码，就在当前目录，创建一个隐藏文件夹 <code>.env</code> 作为虚拟环境。</p>
<p>然后激活虚拟环境：</p>
<ul>
<li>windows</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.env\Scripts\activate.bat</span><br></pre></td></tr></table></figure>
<p>或者 powershell 下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.env\Scripts\Activate.ps1</span><br></pre></td></tr></table></figure>
<ul>
<li>Linux</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">souce .env/bin/activate</span><br></pre></td></tr></table></figure>
<p>激活后，可以正常使用 pip 安装需要的组件。</p>
<p>完成开发打包时，将虚拟环境中的依赖导出，命令是：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip freeze &gt; requirements.txt</span><br></pre></td></tr></table></figure>
<p>即，将依赖导出到 requirements.txt 文本文件中。</p>
<p>如何在新环境中安装呢？</p>
<p>将 requirements.txt 和程序一起复制到新环境中，前提是必须安装有 Python。</p>
<p>如有必要，创建一个虚拟环境，激活后，执行：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install -r requirements.txt</span><br></pre></td></tr></table></figure>
<p>就可以安装所以依赖了，然后就可以执行程序了。</p>
<h2 id="总结">总结</h2>
<p>程序是为人服务，所以并没有想象中那么神秘和可怕，每一步，每个设计和特性，都是在解决或者优化一个问题。</p>
<p>只要顺着解决问题的思路走下去，就能进入美妙的程序世界，让程序发挥作用提升效率。</p>
<p>今天从程序如何形成，以及如何运行的角度上，简单地梳理了一下，并说明了 Python 程序开发和迁移的方法，期望能对读者进一步理解程序有所帮助，比心！</p>

    </div>

    
    
    

      <footer class="post-footer">

        

			<div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/images/wechat-qcode.png" alt="太阳雪 wechat" style="width: 200px; max-width: 100%;"/>
    <div>关注我，获得更多精彩内容</div>
</div>

        
		
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021-11-17-acm/" rel="prev" title="因为备考 ACM，耽误了学习咋办？">
      <i class="fa fa-chevron-left"></i> 因为备考 ACM，耽误了学习咋办？
    </a></div>
      <div class="post-nav-item">
    <a href="/2022-02-09-2021-summary/" rel="next" title="2022-02-09-2021_summary">
      2022-02-09-2021_summary <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          
    <div class="comments" id="valine-comments"></div>

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#程序的由来"><span class="nav-number">1.</span> <span class="nav-text">程序的由来</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#程序的运行"><span class="nav-number">2.</span> <span class="nav-text">程序的运行</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#python"><span class="nav-number">3.</span> <span class="nav-text">python</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#虚拟环境"><span class="nav-number">4.</span> <span class="nav-text">虚拟环境</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建虚拟环境"><span class="nav-number">5.</span> <span class="nav-text">创建虚拟环境</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结"><span class="nav-number">6.</span> <span class="nav-text">总结</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="太阳雪"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">太阳雪</p>
  <div class="site-description" itemprop="description">总结 技术 思考 想法</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">88</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">47</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">太阳雪</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://mist.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Mist</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  
  <script>
    (function(){
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x=document.getElementsByTagName("link");
		//Find the last canonical URL
		if(x.length > 0){
			for (i=0;i<x.length;i++){
				if(x[i].rel.toLowerCase() == 'canonical' && x[i].href){
					canonicalURL=x[i].href;
				}
			}
		}
    //Get protocol
	    if (!canonicalURL){
	    	curProtocol = window.location.protocol.split(':')[0];
	    }
	    else{
	    	curProtocol = canonicalURL.split(':')[0];
	    }
      //Get current URL if the canonical URL does not exist
	    if (!canonicalURL) canonicalURL = window.location.href;
	    //Assign script content. Replace current URL with the canonical URL
      !function(){var e=/([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,r=canonicalURL,t=document.referrer;if(!e.test(r)){var n=(String(curProtocol).toLowerCase() === 'https')?"https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif":"//api.share.baidu.com/s.gif";t?(n+="?r="+encodeURIComponent(document.referrer),r&&(n+="&l="+r)):r&&(n+="?l="+r);var i=new Image;i.src=n}}(window);})();
  </script>















  

  


<script>
NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
  NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
    var GUEST = ['nick', 'mail', 'link'];
    var guest = 'nick,mail';
    guest = guest.split(',').filter(item => {
      return GUEST.includes(item);
    });
    new Valine({
      el         : '#valine-comments',
      verify     : false,
      notify     : false,
      appId      : 'teRj7yeJj0xpfGKLJ5uFdbIu-gzGzoHsz',
      appKey     : '3uie0p1nxouCCnkjiXTEBeLd',
      placeholder: "您的关注是我的动力",
      avatar     : 'mm',
      meta       : guest,
      pageSize   : '10' || 10,
      visitor    : true,
      lang       : 'zh-cn' || 'zh-cn',
      path       : location.pathname,
      recordIP   : false,
      serverURLs : ''
    });
  }, window.Valine);
});
</script>

</body>
</html>
